package com.wanmait.movie.webController;

import com.wanmait.movie.entity.User;
import com.wanmait.movie.service.OrderDetailsService;
import com.wanmait.movie.service.OrdersService;
import com.wanmait.movie.util.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("web/order")
public class OrderController {
    @Resource
    private OrdersService ordersService;
    @Resource
    private OrderDetailsService orderDetailsService;

    @GetMapping("list")
    public AjaxResult list(HttpServletRequest request) {
        System.out.println(request.getAttribute("user"));
        return AjaxResult.success(ordersService.getUserOrdersList((User) request.getAttribute("user")));
    }

    @GetMapping("details")
    public AjaxResult details(String orderNumber){
        return AjaxResult.success(orderDetailsService.orderDetailsList(orderNumber));
    }
}
